﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class FreeStyle : Shape
    {
        private List<Point> points;
        private Point lastPoint;
        public override Point LastPoint { get { return lastPoint; }
            set { points.Add(value.Copy());
                lastPoint = value;
            }
        }

        public FreeStyle (Point first)
        {
            FirstPoint = first;
            points = new List<Point>{FirstPoint.Copy()};// todo make constant so no need for deepCopy
        }
        public override void Draw(Graphics g)
        {
            if (points.Count <= 1)//todo microsoft doesnt say what happens if only 1 point in list
                return;
            g.DrawLines(new Pen(this.Color),points.ToArray());
        }
    }
   public static class Extensions
   {
       public static Point Copy(this Point point)
       {
           return new Point(point.X,point.Y);
       }
   }
}
